package org.intrasearch.spider;

import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.intrasearch.core.FileArtifact;

/**
 * PATISDG 10.11.2009
 */
public class FileArtifactMatcher extends BaseMatcher<FileArtifact>
{
    private final String fileName;
    private final long fileSize;
    private final int urlCount;

    public FileArtifactMatcher(String fileName, long fileSize, int urlCount)
    {
        this.fileName = fileName;
        this.fileSize = fileSize;
        this.urlCount = urlCount;
    }

    public void describeTo(Description description)
    {
        description.appendText("FileArtifact: ").appendValueList("[",",","]",fileName, fileSize, urlCount);
    }

    public boolean matches(Object o)
    {
        if (!(o instanceof FileArtifact))
        {
            return false;
        }
        FileArtifact fileArtifact = (FileArtifact) o;
        return fileName.equals(fileArtifact.getName()) && fileSize == fileArtifact.getFileSize() && urlCount == fileArtifact.getUrls().size();
    }
}
